<template>
  <div class="app3">
    子组件2
    <h4>资产：{{ money }}亿美元</h4>
    <h4>这是一辆：{{ car.brand }}</h4>
    <h4>价值：{{ car.price }}万人民币</h4>
    <button @click="updateMoney(10)">资产叠加</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { inject } from "vue";

let { money, updateMoney } = inject("money", { money: 0, updateMoney: (value: number) => { } });
// inject接收父组件(可跨组件传值)传过来的值 {brand:'未知',price:0}为了表明数据的类型
let car = inject("car",{brand:'未知',price:0});
</script>

<style scoped>
.app3 {
  padding: 10px;
  margin: 10px;
  background-color: orange;
  border-radius: 5px;
  box-shadow: 0 0 10px;
}
</style>
